package com.iot.system.service.impl;

import java.util.Date;
import java.util.List;
import com.iot.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iot.system.mapper.DeviceStateLogsMapper;
import com.iot.system.domain.DeviceStateLogs;
import com.iot.system.service.IDeviceStateLogsService;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author iot
 * @date 2024-11-22
 */
@Service
public class DeviceStateLogsServiceImpl implements IDeviceStateLogsService 
{
    @Autowired
    private DeviceStateLogsMapper deviceStateLogsMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public DeviceStateLogs selectDeviceStateLogsById(Long id)
    {
        return deviceStateLogsMapper.selectDeviceStateLogsById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param deviceStateLogs 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<DeviceStateLogs> selectDeviceStateLogsList(DeviceStateLogs deviceStateLogs)
    {
        return deviceStateLogsMapper.selectDeviceStateLogsList(deviceStateLogs);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param deviceStateLogs 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertDeviceStateLogs(DeviceStateLogs deviceStateLogs)
    {
        deviceStateLogs.setCreateTime(DateUtils.getNowDate());
        return deviceStateLogsMapper.insertDeviceStateLogs(deviceStateLogs);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param deviceStateLogs 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateDeviceStateLogs(DeviceStateLogs deviceStateLogs)
    {
        deviceStateLogs.setUpdateTime(DateUtils.getNowDate());
        return deviceStateLogsMapper.updateDeviceStateLogs(deviceStateLogs);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteDeviceStateLogsByIds(Long[] ids)
    {
        return deviceStateLogsMapper.deleteDeviceStateLogsByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteDeviceStateLogsById(Long id)
    {
        return deviceStateLogsMapper.deleteDeviceStateLogsById(id);
    }

    @Override
    public DeviceStateLogs selectDeviceStateLogsByDeviceId(Long deviceId, Integer deviceState) {
        return deviceStateLogsMapper.selectDeviceStateLogsByDeviceId(deviceId,deviceState);
    }

    @Override
    public Integer getDeviceStateLogsData(Date nowDate) {
        Integer count =deviceStateLogsMapper.getDeviceStateLogsData(nowDate);
        if(count!=null){
            return count;
        }
        return 0;
    }
}
